package com.wdf.dota;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;

import com.wdf.bean.Dota2EquipmentDialog;
import com.wdf.bean.DotaEquipment;
import com.wdf.bean.DotaEquipmentDialog;
import com.wdf.bean.Equipment;



import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.text.Html;
import android.util.Log;
import android.view.View;
import android.view.animation.AnimationSet;
import android.view.animation.TranslateAnimation;
import android.widget.Button;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;

public class EquipmentActivity extends Activity implements OnCheckedChangeListener{
	
	private RadioGroup mRadioGroup;
	private RadioButton mRadioButton1;
	private RadioButton mRadioButton2;
	private RadioButton mRadioButton3;



	private float mCurrentCheckedRadioLeft;//当前被选中的RadioButton距离左侧的距离
	private HorizontalScrollView mHorizontalScrollView;//上面的水平滚动控件
	private ViewPager mViewPager;	//下方的可横向拖动的控件
	private ArrayList<View> mViews;//用来存放下方滚动的layout(layout_1,layout_2,layout_3)
	
	private Bundle bundle;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		 setContentView(R.layout.dota_equi_menu);
	        
	        iniController();
	        iniListener();
	        iniVariable();
	        
	        mRadioButton1.setChecked(true);
	        mViewPager.setCurrentItem(1);
	        mCurrentCheckedRadioLeft = getCurrentCheckedRadioLeft();
	        
	        
	        initEquipment();
	    
	}
	
	private void initEquipment(){
		//基础
		String[] basic = Equipment.Equipment_basic;
		for(String equi : basic){
			int resID = getResources().getIdentifier(equi, "id", "com.wdf.dota"); 
			ImageView view = (ImageView)mViews.get(1).findViewById(resID);
   		    InputStream fis;
			try {
				fis = getAssets().open( "dota/"+equi +".png");
				Bitmap bm = BitmapFactory.decodeStream(fis);
				view.setImageBitmap(bm);
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		//合成
				String[] combining = Equipment.Equipment_combining;
				for (String equi : combining) {
					int resID = getResources()
							.getIdentifier(equi, "id", "com.wdf.dota");
					ImageView view = (ImageView) mViews.get(2).findViewById(resID);
					InputStream fis;
					try {
						fis = getAssets().open("dota/" + equi + ".png");
						Bitmap bm = BitmapFactory.decodeStream(fis);
						view.setImageBitmap(bm);
					} catch (IOException e) {
						e.printStackTrace();
					}
				}
				
				//神秘
				String[] mystical = Equipment.Equipment_mystical;
				for (String equi : mystical) {
					int resID = getResources()
							.getIdentifier(equi, "id", "com.wdf.dota");
					ImageView view = (ImageView) mViews.get(3).findViewById(resID);
					InputStream fis;
					try {
						fis = getAssets().open("dota/" + equi + ".png");
						Bitmap bm = BitmapFactory.decodeStream(fis);
						view.setImageBitmap(bm);
					} catch (IOException e) {
						e.printStackTrace();
					}
				}
		
	}
	
	
	  private void iniVariable() {
			// TODO Auto-generated method stub
	    	mViews = new ArrayList<View>();
	    	mViews.add(getLayoutInflater().inflate(R.layout.dota_equi_menu0, null));
	    	mViews.add(getLayoutInflater().inflate(R.layout.dota_equi_menu1, null));
	    	mViews.add(getLayoutInflater().inflate(R.layout.dota_equi_menu2, null));
	    	mViews.add(getLayoutInflater().inflate(R.layout.dota_equi_menu3, null));
	    
	    	
	    	mViewPager.setAdapter(new MyPagerAdapter());//设置ViewPager的适配器
		}
	    
	    /**
		 * RadioGroup点击CheckedChanged监听
		 */
		@Override
		public void onCheckedChanged(RadioGroup group, int checkedId) {
			
			AnimationSet _AnimationSet = new AnimationSet(true);
			TranslateAnimation _TranslateAnimation;
			

			if (checkedId == R.id.btn1) {
				_TranslateAnimation = new TranslateAnimation(mCurrentCheckedRadioLeft, getResources().getDimension(R.dimen.rdo1), 0f, 0f);
				_AnimationSet.addAnimation(_TranslateAnimation);
				_AnimationSet.setFillBefore(false);
				_AnimationSet.setFillAfter(true);
				_AnimationSet.setDuration(100);

				mViewPager.setCurrentItem(1);//让下方ViewPager跟随上面的HorizontalScrollView切换
			}else if (checkedId == R.id.btn2) {
				_TranslateAnimation = new TranslateAnimation(mCurrentCheckedRadioLeft, getResources().getDimension(R.dimen.rdo2), 0f, 0f);

				_AnimationSet.addAnimation(_TranslateAnimation);
				_AnimationSet.setFillBefore(false);
				_AnimationSet.setFillAfter(true);
				_AnimationSet.setDuration(100);

			
		
				
				mViewPager.setCurrentItem(2);
			}else if (checkedId == R.id.btn3) {
				_TranslateAnimation = new TranslateAnimation(mCurrentCheckedRadioLeft, getResources().getDimension(R.dimen.rdo3), 0f, 0f);
				
				_AnimationSet.addAnimation(_TranslateAnimation);
				_AnimationSet.setFillBefore(false);
				_AnimationSet.setFillAfter(true);
				_AnimationSet.setDuration(100);
				
			
		
				
				mViewPager.setCurrentItem(3);
			}
			
			mCurrentCheckedRadioLeft = getCurrentCheckedRadioLeft();//更新当前蓝色横条距离左边的距离
			
			Log.i("zj", "getCurrentCheckedRadioLeft="+getCurrentCheckedRadioLeft());
			Log.i("zj", "getDimension="+getResources().getDimension(R.dimen.rdo2));
			
			mHorizontalScrollView.smoothScrollTo((int)mCurrentCheckedRadioLeft-(int)getResources().getDimension(R.dimen.rdo2), 0);
		}
	    
		/**
	     * 获得当前被选中的RadioButton距离左侧的距离
	     */
		private float getCurrentCheckedRadioLeft() {
			// TODO Auto-generated method stub
			if (mRadioButton1.isChecked()) {
				//Log.i("zj", "currentCheckedRadioLeft="+getResources().getDimension(R.dimen.rdo1));
				return getResources().getDimension(R.dimen.rdo1);
			}else if (mRadioButton2.isChecked()) {
				//Log.i("zj", "currentCheckedRadioLeft="+getResources().getDimension(R.dimen.rdo2));
				return getResources().getDimension(R.dimen.rdo2);
			}else if (mRadioButton3.isChecked()) {
				//Log.i("zj", "currentCheckedRadioLeft="+getResources().getDimension(R.dimen.rdo3));
				return getResources().getDimension(R.dimen.rdo3);
			}
			return 0f;
		}

		private void iniListener() {
			// TODO Auto-generated method stub
			
			mRadioGroup.setOnCheckedChangeListener(this);
			
			
			mViewPager.setOnPageChangeListener(new MyPagerOnPageChangeListener());
		}

		private void iniController() {
			// TODO Auto-generated method stub
			mRadioGroup = (RadioGroup)findViewById(R.id.radioGroup);
			mRadioButton1 = (RadioButton)findViewById(R.id.btn1);
			mRadioButton2 = (RadioButton)findViewById(R.id.btn2);
			mRadioButton3 = (RadioButton)findViewById(R.id.btn3);

			

			
			mHorizontalScrollView = (HorizontalScrollView)findViewById(R.id.horizontalScrollView);
			
			mViewPager = (ViewPager)findViewById(R.id.pager);
		}

		/**
		 * ViewPager的适配器
		 * @author zj
		 * 2012-5-24 下午2:26:57
		 */
		private class MyPagerAdapter extends PagerAdapter{

			@Override
			public void destroyItem(View v, int position, Object obj) {
				// TODO Auto-generated method stub
				((ViewPager)v).removeView(mViews.get(position));
			}

			@Override
			public void finishUpdate(View arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public int getCount() {
				// TODO Auto-generated method stub
				return mViews.size();
			}

			@Override
			public Object instantiateItem(View v, int position) {
				((ViewPager)v).addView(mViews.get(position));
				return mViews.get(position);
			}

			@Override
			public boolean isViewFromObject(View arg0, Object arg1) {
				// TODO Auto-generated method stub
				return arg0 == arg1;
			}

			@Override
			public void restoreState(Parcelable arg0, ClassLoader arg1) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public Parcelable saveState() {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public void startUpdate(View arg0) {
				// TODO Auto-generated method stub
				
			}
			
		}
		/**
		 * ViewPager的PageChangeListener(页面改变的监听器)
		 * @author zj
		 * 2012-5-24 下午3:14:27
		 */
		private class MyPagerOnPageChangeListener implements OnPageChangeListener{

			@Override
			public void onPageScrollStateChanged(int arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void onPageScrolled(int arg0, float arg1, int arg2) {
				// TODO Auto-generated method stub
				
			}
			/**
			 * 滑动ViewPager的时候,让上方的HorizontalScrollView自动切换
			 */
			@Override
			public void onPageSelected(int position) {
				// TODO Auto-generated method stub
				//Log.i("zj", "position="+position);
				
				if (position == 0) {
					mViewPager.setCurrentItem(1);
				}else if (position == 1) {
					mRadioButton1.performClick();
				}else if (position == 2) {
					mRadioButton2.performClick();
				}else if (position == 3) {
					mRadioButton3.performClick();
				}else if (position == 4) {
					mViewPager.setCurrentItem(3);
				}
			}
			
		}

	public void myHandler(View target) {
		switch (target.getId()) {
		case R.id.store1_1: showDisplay("store1_1");break;
		case R.id.store1_10: showDisplay("store1_10");break;
		case R.id.store1_11: showDisplay("store1_11");break;
		case R.id.store1_12: showDisplay("store1_12");break;
		case R.id.store1_2: showDisplay("store1_2");break;
		case R.id.store1_3: showDisplay("store1_3");break;
		case R.id.store1_4: showDisplay("store1_4");break;
		case R.id.store1_5: showDisplay("store1_5");break;
		case R.id.store1_6: showDisplay("store1_6");break;
		case R.id.store1_7: showDisplay("store1_7");break;
		case R.id.store1_8: showDisplay("store1_8");break;
		case R.id.store1_9: showDisplay("store1_9");break;
		case R.id.store2_1: showDisplay("store2_1");break;
		case R.id.store2_10: showDisplay("store2_10");break;
		case R.id.store2_12: showDisplay("store2_12");break;
		case R.id.store2_2: showDisplay("store2_2");break;
		case R.id.store2_3: showDisplay("store2_3");break;
		case R.id.store2_4: showDisplay("store2_4");break;
		case R.id.store2_5: showDisplay("store2_5");break;
		case R.id.store2_6: showDisplay("store2_6");break;
		case R.id.store2_7: showDisplay("store2_7");break;
		case R.id.store2_8: showDisplay("store2_8");break;
		case R.id.store2_9: showDisplay("store2_9");break;
		case R.id.store3_1: showDisplay("store3_1");break;
		case R.id.store3_10: showDisplay("store3_10");break;
		case R.id.store3_11: showDisplay("store3_11");break;
		case R.id.store3_12: showDisplay("store3_12");break;
		case R.id.store3_2: showDisplay("store3_2");break;
		case R.id.store3_3: showDisplay("store3_3");break;
		case R.id.store3_4: showDisplay("store3_4");break;
		case R.id.store3_5: showDisplay("store3_5");break;
		case R.id.store3_6: showDisplay("store3_6");break;
		case R.id.store3_7: showDisplay("store3_7");break;
		case R.id.store3_8: showDisplay("store3_8");break;
		case R.id.store3_9: showDisplay("store3_9");break;
		case R.id.store4_1: showDisplay("store4_1");break;
		case R.id.store4_10: showDisplay("store4_10");break;
		case R.id.store4_11: showDisplay("store4_11");break;
		case R.id.store4_12: showDisplay("store4_12");break;
		case R.id.store4_2: showDisplay("store4_2");break;
		case R.id.store4_3: showDisplay("store4_3");break;
		case R.id.store4_4: showDisplay("store4_4");break;
		case R.id.store4_5: showDisplay("store4_5");break;
		case R.id.store4_6: showDisplay("store4_6");break;
		case R.id.store4_7: showDisplay("store4_7");break;
		case R.id.store4_8: showDisplay("store4_8");break;
		case R.id.store4_9: showDisplay("store4_9");break;
		case R.id.store10_1: showDisplay("store10_1");break;
		case R.id.store10_10: showDisplay("store10_10");break;
		case R.id.store10_11: showDisplay("store10_11");break;
		case R.id.store10_12: showDisplay("store10_12");break;
		case R.id.store10_2: showDisplay("store10_2");break;
		case R.id.store10_3: showDisplay("store10_3");break;
		case R.id.store10_4: showDisplay("store10_4");break;
		case R.id.store10_5: showDisplay("store10_5");break;
		case R.id.store10_6: showDisplay("store10_6");break;
		case R.id.store10_7: showDisplay("store10_7");break;
		case R.id.store10_8: showDisplay("store10_8");break;
		case R.id.store10_9: showDisplay("store10_9");break;
		case R.id.store5_1: showDisplay("store5_1");break;
		case R.id.store5_10: showDisplay("store5_10");break;
		case R.id.store5_11: showDisplay("store5_11");break;
		case R.id.store5_12: showDisplay("store5_12");break;
		case R.id.store5_2: showDisplay("store5_2");break;
		case R.id.store5_3: showDisplay("store5_3");break;
		case R.id.store5_4: showDisplay("store5_4");break;
		case R.id.store5_5: showDisplay("store5_5");break;
		case R.id.store5_6: showDisplay("store5_6");break;
		case R.id.store5_7: showDisplay("store5_7");break;
		case R.id.store5_8: showDisplay("store5_8");break;
		case R.id.store5_9: showDisplay("store5_9");break;
		case R.id.store6_1: showDisplay("store6_1");break;
		case R.id.store6_10: showDisplay("store6_10");break;
		case R.id.store6_11: showDisplay("store6_11");break;
		case R.id.store6_12: showDisplay("store6_12");break;
		case R.id.store6_2: showDisplay("store6_2");break;
		case R.id.store6_3: showDisplay("store6_3");break;
		case R.id.store6_4: showDisplay("store6_4");break;
		case R.id.store6_5: showDisplay("store6_5");break;
		case R.id.store6_6: showDisplay("store6_6");break;
		case R.id.store6_7: showDisplay("store6_7");break;
		case R.id.store6_8: showDisplay("store6_8");break;
		case R.id.store6_9: showDisplay("store6_9");break;
		case R.id.store7_1: showDisplay("store7_1");break;
		case R.id.store7_10: showDisplay("store7_10");break;
		case R.id.store7_11: showDisplay("store7_11");break;
		case R.id.store7_12: showDisplay("store7_12");break;
		case R.id.store7_2: showDisplay("store7_2");break;
		case R.id.store7_3: showDisplay("store7_3");break;
		case R.id.store7_4: showDisplay("store7_4");break;
		case R.id.store7_5: showDisplay("store7_5");break;
		case R.id.store7_6: showDisplay("store7_6");break;
		case R.id.store7_7: showDisplay("store7_7");break;
		case R.id.store7_8: showDisplay("store7_8");break;
		case R.id.store7_9: showDisplay("store7_9");break;
		case R.id.store8_1: showDisplay("store8_1");break;
		case R.id.store8_10: showDisplay("store8_10");break;
		case R.id.store8_2: showDisplay("store8_2");break;
		case R.id.store8_3: showDisplay("store8_3");break;
		case R.id.store8_4: showDisplay("store8_4");break;
		case R.id.store8_5: showDisplay("store8_5");break;
		case R.id.store8_6: showDisplay("store8_6");break;
		case R.id.store8_7: showDisplay("store8_7");break;
		case R.id.store8_8: showDisplay("store8_8");break;
		case R.id.store8_9: showDisplay("store8_9");break;
		case R.id.store9_1: showDisplay("store9_1");break;
		case R.id.store9_10: showDisplay("store9_10");break;
		case R.id.store9_11: showDisplay("store9_11");break;
		case R.id.store9_12: showDisplay("store9_12");break;
		case R.id.store9_2: showDisplay("store9_2");break;
		case R.id.store9_3: showDisplay("store9_3");break;
		case R.id.store9_4: showDisplay("store9_4");break;
		case R.id.store9_5: showDisplay("store9_5");break;
		case R.id.store9_6: showDisplay("store9_6");break;
		case R.id.store9_7: showDisplay("store9_7");break;
		case R.id.store9_8: showDisplay("store9_8");break;
		case R.id.store9_9: showDisplay("store9_9");break;
		case R.id.store11_1: showDisplay("store11_1");break;
		case R.id.store11_10: showDisplay("store11_10");break;
		case R.id.store11_11: showDisplay("store11_11");break;
		case R.id.store11_12: showDisplay("store11_12");break;
		case R.id.store11_2: showDisplay("store11_2");break;
		case R.id.store11_3: showDisplay("store11_3");break;
		case R.id.store11_4: showDisplay("store11_4");break;
		case R.id.store11_5: showDisplay("store11_5");break;
		case R.id.store11_6: showDisplay("store11_6");break;
		case R.id.store11_7: showDisplay("store11_7");break;
		case R.id.store11_8: showDisplay("store11_8");break;
		case R.id.store11_9: showDisplay("store11_9");break;

		
		
		
		/*bundle = new Bundle();
		Intent intent = new Intent(this, EquimentViewActivity.class);
		String equipment ="";
		String equipmentDes="";
		switch (target.getId()) {
		case R.id.store1_1:equipment ="store1_1";equipmentDes=Equipment.store1_1;break;
		case R.id.store1_2:equipment ="store1_2";equipmentDes=Equipment.store1_2;break;
		case R.id.store1_3:equipment ="store1_3";equipmentDes=Equipment.store1_3;break;
		case R.id.store1_4:equipment ="store1_4";equipmentDes=Equipment.store1_4;break;
		case R.id.store1_5:equipment ="store1_5";equipmentDes=Equipment.store1_5;break;
		case R.id.store1_6:equipment ="store1_6";equipmentDes=Equipment.store1_6;break;
		case R.id.store1_7:equipment ="store1_7";equipmentDes=Equipment.store1_7;break;
		case R.id.store1_8:equipment ="store1_8";equipmentDes=Equipment.store1_8;break;
		case R.id.store1_9:equipment ="store1_9";equipmentDes=Equipment.store1_9;break;
		case R.id.store1_10:equipment ="store1_10";equipmentDes=Equipment.store1_10;break;
		case R.id.store1_11:equipment ="store1_11";equipmentDes=Equipment.store1_11;break;
		case R.id.store1_12:equipment ="store1_12";equipmentDes=Equipment.store1_12;break;

		case R.id.store2_1:equipment ="store2_1";equipmentDes=Equipment.store2_1;break;
		case R.id.store2_2:equipment ="store2_2";equipmentDes=Equipment.store2_2;break;
		case R.id.store2_3:equipment ="store2_3";equipmentDes=Equipment.store2_3;break;
		case R.id.store2_4:equipment ="store2_4";equipmentDes=Equipment.store2_4;break;
		case R.id.store2_5:equipment ="store2_5";equipmentDes=Equipment.store2_5;break;
		case R.id.store2_6:equipment ="store2_6";equipmentDes=Equipment.store2_6;break;
		case R.id.store2_7:equipment ="store2_7";equipmentDes=Equipment.store2_7;break;
		case R.id.store2_8:equipment ="store2_8";equipmentDes=Equipment.store2_8;break;
		case R.id.store2_9:equipment ="store2_9";equipmentDes=Equipment.store2_9;break;
		case R.id.store2_10:equipment ="store2_10";equipmentDes=Equipment.store2_10;break;
		case R.id.store2_12:equipment ="store2_12";equipmentDes=Equipment.store2_12;break;
		case R.id.store3_1:equipment ="store3_1";equipmentDes=Equipment.store3_1;break;
		case R.id.store3_2:equipment ="store3_2";equipmentDes=Equipment.store3_2;break;
		case R.id.store3_3:equipment ="store3_3";equipmentDes=Equipment.store3_3;break;
		case R.id.store3_4:equipment ="store3_4";equipmentDes=Equipment.store3_4;break;
		case R.id.store3_5:equipment ="store3_5";equipmentDes=Equipment.store3_5;break;
		case R.id.store3_6:equipment ="store3_6";equipmentDes=Equipment.store3_6;break;
		case R.id.store3_7:equipment ="store3_7";equipmentDes=Equipment.store3_7;break;
		case R.id.store3_8:equipment ="store3_8";equipmentDes=Equipment.store3_8;break;
		case R.id.store3_9:equipment ="store3_9";equipmentDes=Equipment.store3_9;break;
		case R.id.store3_10:equipment ="store3_10";equipmentDes=Equipment.store3_10;break;
		case R.id.store3_11:equipment ="store3_11";equipmentDes=Equipment.store3_11;break;
		case R.id.store3_12:equipment ="store3_12";equipmentDes=Equipment.store3_12;break;
		case R.id.store4_1:equipment ="store4_1";equipmentDes=Equipment.store4_1;break;
		case R.id.store4_2:equipment ="store4_2";equipmentDes=Equipment.store4_2;break;
		case R.id.store4_3:equipment ="store4_3";equipmentDes=Equipment.store4_3;break;
		case R.id.store4_4:equipment ="store4_4";equipmentDes=Equipment.store4_4;break;
		case R.id.store4_5:equipment ="store4_5";equipmentDes=Equipment.store4_5;break;
		case R.id.store4_6:equipment ="store4_6";equipmentDes=Equipment.store4_6;break;
		case R.id.store4_7:equipment ="store4_7";equipmentDes=Equipment.store4_7;break;
		case R.id.store4_8:equipment ="store4_8";equipmentDes=Equipment.store4_8;break;
		case R.id.store4_9:equipment ="store4_9";equipmentDes=Equipment.store4_9;break;
		case R.id.store4_10:equipment ="store4_10";equipmentDes=Equipment.store4_10;break;
		case R.id.store4_11:equipment ="store4_11";equipmentDes=Equipment.store4_11;break;
		case R.id.store4_12:equipment ="store4_12";equipmentDes=Equipment.store4_12;break;
		case R.id.store5_1:equipment ="store5_1";equipmentDes=Equipment.store5_1;break;
		case R.id.store5_2:equipment ="store5_2";equipmentDes=Equipment.store5_2;break;
		case R.id.store5_3:equipment ="store5_3";equipmentDes=Equipment.store5_3;break;
		case R.id.store5_4:equipment ="store5_4";equipmentDes=Equipment.store5_4;break;
		case R.id.store5_5:equipment ="store5_5";equipmentDes=Equipment.store5_5;break;
		case R.id.store5_6:equipment ="store5_6";equipmentDes=Equipment.store5_6;break;
		case R.id.store5_7:equipment ="store5_7";equipmentDes=Equipment.store5_7;break;
		case R.id.store5_8:equipment ="store5_8";equipmentDes=Equipment.store5_8;break;
		case R.id.store5_9:equipment ="store5_9";equipmentDes=Equipment.store5_9;break;
		case R.id.store5_10:equipment ="store5_10";equipmentDes=Equipment.store5_10;break;
		case R.id.store5_11:equipment ="store5_11";equipmentDes=Equipment.store5_11;break;
		case R.id.store5_12:equipment ="store5_12";equipmentDes=Equipment.store5_12;break;
		case R.id.store6_1:equipment ="store6_1";equipmentDes=Equipment.store6_1;break;
		case R.id.store6_2:equipment ="store6_2";equipmentDes=Equipment.store6_2;break;
		case R.id.store6_3:equipment ="store6_3";equipmentDes=Equipment.store6_3;break;
		case R.id.store6_4:equipment ="store6_4";equipmentDes=Equipment.store6_4;break;
		case R.id.store6_5:equipment ="store6_5";equipmentDes=Equipment.store6_5;break;
		case R.id.store6_6:equipment ="store6_6";equipmentDes=Equipment.store6_6;break;
		case R.id.store6_7:equipment ="store6_7";equipmentDes=Equipment.store6_7;break;
		case R.id.store6_8:equipment ="store6_8";equipmentDes=Equipment.store6_8;break;
		case R.id.store6_9:equipment ="store6_9";equipmentDes=Equipment.store6_9;break;
		case R.id.store6_10:equipment ="store6_10";equipmentDes=Equipment.store6_10;break;
		case R.id.store6_11:equipment ="store6_11";equipmentDes=Equipment.store6_11;break;
		case R.id.store6_12:equipment ="store6_12";equipmentDes=Equipment.store6_12;break;
		case R.id.store7_1:equipment ="store7_1";equipmentDes=Equipment.store7_1;break;
		case R.id.store7_2:equipment ="store7_2";equipmentDes=Equipment.store7_2;break;
		case R.id.store7_3:equipment ="store7_3";equipmentDes=Equipment.store7_3;break;
		case R.id.store7_4:equipment ="store7_4";equipmentDes=Equipment.store7_4;break;
		case R.id.store7_5:equipment ="store7_5";equipmentDes=Equipment.store7_5;break;
		case R.id.store7_6:equipment ="store7_6";equipmentDes=Equipment.store7_6;break;
		case R.id.store7_7:equipment ="store7_7";equipmentDes=Equipment.store7_7;break;
		case R.id.store7_8:equipment ="store7_8";equipmentDes=Equipment.store7_8;break;
		case R.id.store7_9:equipment ="store7_9";equipmentDes=Equipment.store7_9;break;
		case R.id.store7_10:equipment ="store7_10";equipmentDes=Equipment.store7_10;break;
		case R.id.store7_11:equipment ="store7_11";equipmentDes=Equipment.store7_11;break;
		case R.id.store7_12:equipment ="store7_12";equipmentDes=Equipment.store7_12;break;
		case R.id.store8_1:equipment ="store8_1";equipmentDes=Equipment.store8_1;break;
		case R.id.store8_2:equipment ="store8_2";equipmentDes=Equipment.store8_2;break;
		case R.id.store8_3:equipment ="store8_3";equipmentDes=Equipment.store8_3;break;
		case R.id.store8_4:equipment ="store8_4";equipmentDes=Equipment.store8_4;break;
		case R.id.store8_5:equipment ="store8_5";equipmentDes=Equipment.store8_5;break;
		case R.id.store8_6:equipment ="store8_6";equipmentDes=Equipment.store8_6;break;
		case R.id.store8_7:equipment ="store8_7";equipmentDes=Equipment.store8_7;break;
		case R.id.store8_8:equipment ="store8_8";equipmentDes=Equipment.store8_8;break;
		case R.id.store8_9:equipment ="store8_9";equipmentDes=Equipment.store8_9;break;
		case R.id.store8_10:equipment ="store8_10";equipmentDes=Equipment.store8_10;break;

		case R.id.store9_1:equipment ="store9_1";equipmentDes=Equipment.store9_1;break;
		case R.id.store9_2:equipment ="store9_2";equipmentDes=Equipment.store9_2;break;
		case R.id.store9_3:equipment ="store9_3";equipmentDes=Equipment.store9_3;break;
		case R.id.store9_4:equipment ="store9_4";equipmentDes=Equipment.store9_4;break;
		case R.id.store9_5:equipment ="store9_5";equipmentDes=Equipment.store9_5;break;
		case R.id.store9_6:equipment ="store9_6";equipmentDes=Equipment.store9_6;break;
		case R.id.store9_7:equipment ="store9_7";equipmentDes=Equipment.store9_7;break;
		case R.id.store9_8:equipment ="store9_8";equipmentDes=Equipment.store9_8;break;
		case R.id.store9_9:equipment ="store9_9";equipmentDes=Equipment.store9_9;break;
		case R.id.store9_10:equipment ="store9_10";equipmentDes=Equipment.store9_10;break;
		case R.id.store9_11:equipment ="store9_11";equipmentDes=Equipment.store9_11;break;
		case R.id.store9_12:equipment ="store9_12";equipmentDes=Equipment.store9_12;break;
		case R.id.store10_1:equipment ="store10_1";equipmentDes=Equipment.store10_1;break;
		case R.id.store10_2:equipment ="store10_2";equipmentDes=Equipment.store10_2;break;
		case R.id.store10_3:equipment ="store10_3";equipmentDes=Equipment.store10_3;break;
		case R.id.store10_4:equipment ="store10_4";equipmentDes=Equipment.store10_4;break;
		case R.id.store10_5:equipment ="store10_5";equipmentDes=Equipment.store10_5;break;
		case R.id.store10_6:equipment ="store10_6";equipmentDes=Equipment.store10_6;break;
		case R.id.store10_7:equipment ="store10_7";equipmentDes=Equipment.store10_7;break;
		case R.id.store10_8:equipment ="store10_8";equipmentDes=Equipment.store10_8;break;
		case R.id.store10_9:equipment ="store10_9";equipmentDes=Equipment.store10_9;break;
		case R.id.store10_10:equipment ="store10_10";equipmentDes=Equipment.store10_10;break;
		case R.id.store10_11:equipment ="store10_11";equipmentDes=Equipment.store10_11;break;
		case R.id.store10_12:equipment ="store10_12";equipmentDes=Equipment.store10_12;break;
		case R.id.store11_1:equipment ="store11_1";equipmentDes=Equipment.store11_1;break;
		case R.id.store11_2:equipment ="store11_2";equipmentDes=Equipment.store11_2;break;
		case R.id.store11_3:equipment ="store11_3";equipmentDes=Equipment.store11_3;break;
		case R.id.store11_4:equipment ="store11_4";equipmentDes=Equipment.store11_4;break;
		case R.id.store11_5:equipment ="store11_5";equipmentDes=Equipment.store11_5;break;
		case R.id.store11_6:equipment ="store11_6";equipmentDes=Equipment.store11_6;break;
		case R.id.store11_7:equipment ="store11_7";equipmentDes=Equipment.store11_7;break;
		case R.id.store11_8:equipment ="store11_8";equipmentDes=Equipment.store11_8;break;
		case R.id.store11_9:equipment ="store11_9";equipmentDes=Equipment.store11_9;break;
		case R.id.store11_10:equipment ="store11_10";equipmentDes=Equipment.store11_10;break;
		case R.id.store11_11:equipment ="store11_11";equipmentDes=Equipment.store11_11;break;
		case R.id.store11_12:equipment ="store11_12";equipmentDes=Equipment.store11_12;break;
        default:
        break;
		
		}
		bundle.putString("equipment", equipment);
		bundle.putString("equipmentDes", equipmentDes);
		intent.putExtras(bundle);
		startActivityForResult(intent, 0);
		*/
		
		}
	}	
	boolean[]  mark = {false,false,false,false,false,false,false,false,false,false,false,false};
	
	public void handlerDisplay(View target){
		
		switch (target.getId()) {
		case R.id.shops01Btn:
		case R.id.shops01RelativeLayout:
			doAction(R.id.shops01Btn,R.id.shops01Display,0);
			break;
		case R.id.shops02Btn:
		case R.id.shops02RelativeLayout:
			doAction(R.id.shops02Btn,R.id.shops02Display,1);
			break;
		case R.id.shops03Btn:
		case R.id.shops03RelativeLayout:
			doAction(R.id.shops03Btn,R.id.shops03Display,2);
			break;
		case R.id.shops04Btn:
		case R.id.shops04RelativeLayout:
			doAction(R.id.shops04Btn,R.id.shops04Display,3);
			break;
		case R.id.shops05RelativeLayout:
		case R.id.shops05Btn:
			doAction(R.id.shops05Btn,R.id.shops05Display,4);
			break;
		case R.id.shops06Btn:
		case R.id.shops06RelativeLayout:
			doAction(R.id.shops06Btn,R.id.shops06Display,5);
			break;
		case R.id.shops07Btn:
		case R.id.shops07RelativeLayout:
			doAction(R.id.shops07Btn,R.id.shops07Display,6);
			break;
		case R.id.shops08Btn:
		case R.id.shops08RelativeLayout:
			doAction(R.id.shops08Btn,R.id.shops08Display,7);
			break;
		case R.id.shops09Btn:
		case R.id.shops09RelativeLayout:
			doAction(R.id.shops09Btn,R.id.shops09Display,8);
			break;
		case R.id.shops10Btn:
		case R.id.shops10RelativeLayout:
			doAction(R.id.shops10Btn,R.id.shops10Display,9);
			break;
		case R.id.shops11Btn:
		case R.id.shops11RelativeLayout:
			doAction(R.id.shops11Btn,R.id.shops11Display,10);
			break;

		}
		
	}
	
	
	public void doAction(int btn,int display,int index){
		Drawable  up = getResources().getDrawable(R.drawable.ud_switch_u_btn_n);
		Drawable  down = getResources().getDrawable(R.drawable.ud_switch_d_btn_n);
		Button button = (Button)this.findViewById(btn);
		LinearLayout ll = (LinearLayout)this.findViewById(display);
		
		if(mark[index]){
			button.setBackgroundDrawable(down);
			ll.setVisibility(View.GONE);
			
		}else{
			button.setBackgroundDrawable(up);
			ll.setVisibility(View.VISIBLE);
		}
		mark[index] = !mark[index] ;
		
	}
	
	
	//添加部分
	public void showDisplay(String item){
		final DotaEquipmentDialog dialog = new DotaEquipmentDialog(EquipmentActivity.this, R.style.MyDialog);
		 dialog.setContentView(R.layout.dota_equi_dialog);
	     Equipment equipment =new Equipment();
	     
	     dialog. setPositiveButton("    ", new android.view.View.OnClickListener() {
				public void onClick(View v) {
					dialog.dismiss();
				}
			    });
	     try {
	    	 String content = equipment.getClass().getField(item).get(equipment).toString();
	    	 dialog.setContent(Html.fromHtml(content));
		} catch (Exception e) {
			// TODO: handle exception
		}
	     dialog.show();
	}

}
